package cn.shadow.module.chess.message.chnChess;

import java.util.HashMap;
import java.util.Map;

/**
 * 象棋的类型
 */
public enum ChessType {
    CHE(1, "车"),
    MA(2, "马"),
    XIANG(3, "象"),
    SHI(4, "士"),
    SHUAI(5, "帅/将"),
    PAO(6, "炮/砲"),
    BING(7, "兵/卒");
    int value;
    String name;

    ChessType(int value, String name) {
        this.value = value;
        this.name = name;
    }

    private final static Map<Integer, ChessType> typeMap = new HashMap<>();

    static {
        ChessType[] values = ChessType.values();
        for (ChessType value : values) {
            typeMap.put(value.value, value);
        }
    }

    public static ChessType getTypeByValue(int value) {
        return typeMap.get(value);
    }

    public String getName() {
        return name;
    }

    public int value() {
        return value;
    }

    @Override
    public String toString() {
        return "[" + "name='" + name + '\'' +
                ", value=" + value +
                ']';
    }
}
